15. Quiz: Match Inputs To Outputs

Test Your Loop Knowledge

In case you want to test any code for the quizzes that follow, there is a code editor at the bottom of this page where you can experiment.

QUIZ QUESTION::

Practice with range

For each below, match the input code to the appropriate output.

ANSWER CHOICES:



Input

Output

print(list(range(4)))

print(list(range(4,8)))

print(list(range(4,10,2)))

print(list(range(0,-5)))

SOLUTION:

Input

Output

print(list(range(4)))

print(list(range(0,-5)))

print(list(range(4,8)))

print(list(range(4,10,2)))

Use the code below to complete the next quiz.

colors = ['Red', 'Blue', 'Green', 'Purple']
lower_colors = [ ]

for color in colors:
    #finish this part

If you want to create a new list called lower_colors, where each color in colors is lower cased, which code line should be inserted into the code block above?

SOLUTION: lower_colors.append(color.lower())

Start Quiz:

# Use the space here to practice whatever you would like pertaining to
# the above quizzes.